<?php $groups = C('APP_GROUP_ARRAY'); ?>
<body>
    <div class="wrap">
        
    <!-- start -->
    <div class="nav">
        <ul class="cc">
            <li<?php if($type == 'admin'): ?> class="current"<?php endif; ?>><a href="<?php echo U('Admin/Node/index',array('type'=>'admin')); ?>">管理端节点</a></li>
            <li<?php if($type == 'front'): ?> class="current"<?php endif; ?>><a href="<?php echo U('Admin/Node/index',array('type'=>'front')); ?>">前台节点</a></li>
        </ul>
    </div>
    
    <div class="mb10">
        <a class="btn J_dialog" href="<?php echo U('Admin/Node/add',array('type'=>$type));?>" title="添加节点" role="button"><span class="add"></span>添加ROOT节点</a>
    </div>
    <form method="post" class="J_ajaxForm" action="<?php echo U('Admin/Node/batch',array('type'=>$type)) ?>" data-role="list">

    <div class="table_list">
        <table width="100%" id="J_table_list" style="table-layout:fixed;">
            <colgroup>
                <col width="30">
                <col width="50">
                <col width="260">
                <col width="130">
                <col width="90">
                <col width="90">
                <col width="78">
                <col>
            </colgroup>
            <thead>
                <tr>
                    <td></td>
                    <td class="tac">顺序</td>
                    <td class="tac">节点名称</td>
                    <td class="tac">分组</td>
                    <td class="tac">模块</td>
                    <td class="tac">操作</td>
                    <td class="tac">显示</td>
                    <td>操作</td>
                </tr>
            </thead>
            <?php $i = 1 ;?>
            <?php foreach($nodes as $node): ?>
            
            <tbody>
                <tr>
                    <?php if(!empty($node['left_menu'])): ?>
                    <td><span class="J_start_icon away_icon" data-id="<?php echo $i; ?>"></span></td>
                    <?php else: ?>
                    <td><span class="zero_icon" data-id="<?php echo $i; ?>"></span></td>
                    <?php endif; ?>
                    <td colspan="2">
                        <input name="root[<?php echo $node['id']; ?>][rank]" type="text" class="input length_0 mr10" value="<?php echo $node['rank']; ?>">
                        <input name="root[<?php echo $node['id']; ?>][name]" type="text" class="input length_4 mr5" value="<?php echo $node['name']; ?>">
                     </td>
                    <td>
                    <select name="root[<?php echo $node['id']; ?>][g]" class="select_2">
                    <option value=""></option>
                    <?php foreach($groups as $key=>$val): ?>
                    <option value="<?php echo $val;?>"<?php if($val==$node['g']) echo ' selected' ?>><?php echo $val;?></option>
                    <?php endforeach; ?>
                    </select>
                    </td>
                    <td><input name="root[<?php echo $node['id']; ?>][m]" type="text" class="input w70" value="<?php echo $node['m']; ?>"></td>
                    <td><input name="root[<?php echo $node['id']; ?>][a]" type="text" class="input w70" value="<?php echo $node['a']; ?>"></td>
                    <td class="tac"><input name="root[<?php echo $node['id']; ?>][status]" type="checkbox" value="<?php echo $node['status']; ?>"<?php if($node['status']==1) echo ' checked'; ?> ></td>
                    <td>
                        <a href="<?php echo U('Admin/Node/add',array('root'=>1,'nid'=>$node['id'])); ?>" class="mr10 J_dialog" title="添加节点">[添加]</a>
                        <a href="<?php echo U('Admin/Node/edit',array('root'=>1,'nid'=>$node['id'])); ?>" class="mr10" title="编辑节点">[编辑]</a>
                        <?php if(empty($node['left_menu'])): ?>
                        <a href="<?php echo U('Admin/Node/delete',array('root'=>1,'nid'=>$node['id'])); ?>" class="mr10 J_ajax_del">[删除]</a>
                        <?php endif; ?>
                    </td>
                </tr>
            </tbody>
            
            <?php if(!empty($node['left_menu'])): ?>
            <tbody id="J_table_list_<?php echo $i; ?>">
                <?php 
                    $lc = count($node['left_menu']);
                    $l  = 1;
                ?>
                <?php foreach($node['left_menu'] as $left): ?>
                <tr>
                <td>&nbsp;</td>
                <td colspan="2">
                    <?php if($lc == $l): ?>
                    <span class="plus_icon plus_end_icon mr10"></span>
                    <?php else: ?>
                    <span class="plus_icon mr10"></span>
                    <?php endif; ?>
                    <input name="main[<?php echo $left['id']; ?>][rank]" type="text" class="input length_0 mr10" value="<?php echo $left['rank']; ?>" style="width:20px;">
                    <input name="main[<?php echo $left['id']; ?>][name]" type="text" class="input w177 mr5" value="<?php echo $left['name']; ?>">
                 </td>
                <td>
                    <select name="main[<?php echo $left['id']; ?>][g]" class="select_2">
                    <option value=""></option>
                    <?php foreach($groups as $key=>$val): ?>
                    <option value="<?php echo $val;?>"<?php if($val==$left['g']) echo ' selected' ?>><?php echo $val;?></option>
                    <?php endforeach; ?>
                    </select>
                </td>
                <td>
                    <input name="main[<?php echo $left['id']; ?>][m]" type="text" class="input w70" value="<?php echo $left['m']; ?>">
                </td>
                <td>
                    <input name="main[<?php echo $left['id']; ?>][a]" type="text" class="input w70" value="<?php echo $left['a']; ?>">
                </td>
                <td class="tac"><input name="main[<?php echo $left['id']; ?>][status]" type="checkbox" value="<?php echo $left['status']; ?>"<?php if($left['status']==1) echo ' checked'; ?> ></td>
                <td>
                    <a href="<?php echo U('Admin/Node/add',array('root'=>2,'nid'=>$left['id'])); ?>" class="mr10 J_dialog" title="添加节点">[添加]</a>
                    <a href="<?php echo U('Admin/Node/edit',array('root'=>2,'nid'=>$left['id'])); ?>" class="mr10" title="编辑节点">[编辑]</a>
                    <?php if(empty($left['node_items'])): ?>
                    <a href="<?php echo U('Admin/Node/delete',array('root'=>2,'nid'=>$left['id'])); ?>" class="mr10 J_ajax_del">[删除]</a>
                    <?php endif; ?>
                </td>
                </tr>
                
                <?php if(!empty($left['node_items'])): ?>
                    <?php 
                        $last_c = count($left['node_items']);
                        $last_i = 1;
                    ?>
                    
                    <?php foreach($left['node_items'] as $last): ?>
                <tr>
                <?php if($lc == $l): ?>
                <td colspan="2">&nbsp;</td>
                <?php else: ?>
                <td>&nbsp;</td>
                <td><span class="plus_icon plus_on_icon mr10"></span></td>
                <?php endif; ?>
                <td>
                <?php if($last_c == $last_i): ?>
                <span class="plus_icon plus_end_icon mr10"></span>
                <?php else: ?>
                <span class="plus_icon mr10"></span>
                <?php endif; ?>
                <input name="main[<?php echo $last['id']; ?>][rank]" type="text" class="input length_0 mr10" value="<?php echo $last['rank']; ?>" style="width:20px;">
                <input name="main[<?php echo $last['id']; ?>][name]" type="text" class="input w127 mr5" value="<?php echo $last['name']; ?>">
                </td>
                <td>
                    <select name="main[<?php echo $last['id']; ?>][g]" class="select_2">
                    <?php foreach($groups as $key=>$val): ?>
                    <option value="<?php echo $val;?>"<?php if($val==$last['g']) echo ' selected' ?>><?php echo $val;?></option>
                    <?php endforeach; ?>
                    </select>
                </td>
                <td>
                    <input name="main[<?php echo $last['id']; ?>][m]" type="text" class="input w70" value="<?php echo $last['m']; ?>">
                </td>
                <td>
                    <input name="main[<?php echo $last['id']; ?>][a]" type="text" class="input w70" value="<?php echo $last['a']; ?>">
                </td>
                <td class="tac"><input name="main[<?php echo $last['id']; ?>][status]" type="checkbox" value="<?php echo $last['status']; ?>"<?php if($last['status']==1) echo ' checked'; ?> ></td>
                <td>
                    <a href="<?php echo U('Admin/Node/edit',array('root'=>3,'nid'=>$last['id'])); ?>" class="mr10" title="编辑节点">[编辑]</a>
                    <a href="<?php echo U('Admin/Node/delete',array('root'=>3,'nid'=>$last['id'])); ?>" class="mr10 J_ajax_del">[删除]</a>
                </td>
                </tr>
                    <?php $last_i++; ?>
                    <?php endforeach; ?>
                <?php endif; ?>

                <?php $l++; ?>
                <?php endforeach; ?>
            </tbody>
            <?php endif; ?>
            
            <?php $i++; ?>
            <?php endforeach; ?>
            
        </table>
    </div>
    <div class="btn_wrap">
        <div class="btn_wrap_pd">
            <button class="btn btn_submit mr10 J_ajax_submit_btn" type="submit">提交</button>
        </div>
    </div>  
    
    </form>
    <!-- end -->
    </div>
<script>
Wind.js(GV.JS_ROOT+ 'pages/admin/common/forumTree_table.js?v=' +GV.JS_VERSION);
</script>
</body>